#include <iostream>
#include "calculator.h"
#include "hello.h"
#include "Arithmetic.h"

void run_calculation() {
    int x = 10;
    int y = 5;

    std::cout << "[run_calculation] x = " << x << ", y = " << y << std::endl;

    int sum = add(x, y);
    std::cout << "[run_calculation] Sum: " << sum << std::endl;

    int diff = subtract(x, y);
    std::cout << "[run_calculation] Difference: " << diff << std::endl;

    if (sum > diff) {
        std::cout << "[run_calculation] Sum is greater than difference." << std::endl;
    } else {
        std::cout << "[run_calculation] Difference is greater or equal to sum." << std::endl;
    }
}

void run_arithmetic(){
    IOperation* op = new Arithmetic();
    std::cout << "Add: " << op->add(10, 5) << "\n";
    std::cout << "Subtract: " << op->subtract(10, 5) << "\n";
    std::cout << "Multiply: " << op->multiply(10, 5) << "\n";

    try {
        std::cout << "Divide: " << op->divide(10, 0) << "\n";
    } catch (const std::invalid_argument& e) {
        std::cerr << "Error: " << e.what() << "\n";
    }

    delete op;
}

int main() {
    std::cout << "[main] Starting program..." << std::endl;
    say_hello();
    run_calculation();
    run_arithmetic();
    std::cout << "[main] Program finished." << std::endl;
    return 0;
}